package com.doumuxie.mapper;

import com.doumuxie.dto.PermissionDto;
import com.doumuxie.dto.UserDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PermissionMapper {

    @Select("<script>" +
            "SELECT\n" +
            "\tp.* \n" +
            "FROM\n" +
            "\tt_user u\n" +
            "\tLEFT JOIN t_user_role ur ON u.id = ur.user_id\n" +
            "\tLEFT JOIN t_role_permission rp ON ur.role_id = rp.role_id\n" +
            "\tLEFT JOIN t_permission p ON rp.permission_id = p.id \n" +
            "WHERE\n" +
            "\tu.id = #{userId} order by p.update_time desc" +
            "</script>")
    List<PermissionDto> permissionList(String userId);
}
